home *** CD-ROM | disk | FTP | other *** search
- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
- /* */
- /* MADE - Macintosh Application Development Essentials */
- /* --------------------------------------------------- */
- /* (c) Sig Software, http://www.sigsoftware.com/ */
- /* */
- /* These files can only be used for experimental purposes. To obtain */
- /* fully commented code, source code for the functions in Essential */
- /* Extras.h and permission for usage in final projects, you must */
- /* purchase a license. See documentation for more information. */
- /* */
- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
- /* */
- /* User Functions.c */
- /* ---------------- */
- /* */
- /* Off the shelf responses to replace with your code. */
- /* */
- /* Version 1.0.0 - 10th November 1996 */
- /* Version 1.1.0 - 29th January 1998 - Modeless dialog support */
- /* Version 1.2.0 - 20th November 1998 - Changed example code */
- /* Version 1.4.0 - 26th May 1999 - Apple item, threading support */
- /* */
- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
- #include "Essential Headers.h"
- #include "Essential Prototypes.h"
-
- enum {
- AppleStart=128*65536,
- AppleAbout,
-
- FileStart=129*65536,
- FileNew,
- FileOpen,
- FileSep1,
- FileClose,
- FileSave,
- FileSaveAs,
- FileSep2,
- FilePageSetup,
- FilePrint,
- FileSep3,
- FileQuit,
-
- EditStart=130*65536,
- EditUndo,
- EditSep1,
- EditCut,
- EditCopy,
- EditPaste,
- EditClear
-
- };
-
- Error MyInitialiseApplication()
- {
- return 0;
- }
-
- void MyClearUpApplication()
- {
- }
-
- void MySuspendApplication()
- {
- if (frontWindow)
- MyDeactivateWindow();
- // this is needed if doesActivateOnFGSwitch build flag is on in target settings
- }
-
- void MyResumeApplication()
- {
- if (frontWindow)
- MyActivateWindow();
- // this is needed if doesActivateOnFGSwitch build flag is on in target settings
- }
-
- void MyPerformIdleTasks()
- {
- #if Add_Threads_Support
- ThreadsWork(appInFront ? 15 : 5);
- // this lets threads work for 15/60ths second if application is in front or
- // 5/60ths second if the application is not in front. Set as desired
- #endif
- }
-
- void MyFreeUpMemory(Size spaceNeeded)
- {
- }
-
- void MySetTheCursor(Point localPoint)
- {
- SetCursor(&qd.arrow);
- }
-
- void MyHandleKeyDown(char keyCharacter, EventRecord* event)
- {
- Str255 windowTitle;
-
- if (frontWindow) { // some silly code to demonstrate key-presses
- GetWTitle(frontWindow, windowTitle);
- if (keyCharacter==0x08) {
- if (*windowTitle)
- (*windowTitle)--;
- } else
- windowTitle[++*windowTitle]=(unsigned char)keyCharacter;
- SetWTitle(frontWindow, windowTitle);
- }
- }
-
- void MyHandleMouseDown(Point localPoint, EventRecord* event)
- {
- InvertRgn(frontWindow->visRgn);
- while (StillDown())
- {}
- InvertRgn(frontWindow->visRgn);
- }
-
- void MyCloseWindow()
- {
- DisposeWindow(frontWindow);
- }
-
- void MyActivateWindow()
- {
- DrawGrowIcon(frontWindow);
- }
-
- void MyDeactivateWindow()
- {
- DrawGrowIcon(frontWindow);
- }
-
- void MyResizeBounds(Rect* growLimits)
- {
- SetRect(growLimits, 128, 64, qd.screenBits.bounds.right,
- qd.screenBits.bounds.bottom);
- }
-
- void MySizedWindow()
- {
- InvalRgn(frontWindow->visRgn);
- }
-
- void MyDrawWindow(WindowPtr drawWindow)
- {
- EraseRgn(drawWindow->visRgn);
- MoveTo(4, 16);
- DrawString("\pThis is a bare shell of MADE");
- DrawGrowIcon(drawWindow);
- }
-
- void MyEnableMenus()
- {
- SetMenuItemEnabled(129, 4, frontWindow!=0);
- }
-
- void MyPerformMenu(long selection)
- {
- Rect windowRect;
-
- switch (selection) {
- case FileNew:
- SetRect(&windowRect, 48, 48, 256, 256);
- NewWindow(0, &windowRect, "\pUntitled", true, zoomDocProc, (WindowPtr)-1, true, 0);
- break;
-
- case FileClose:
- MyCloseWindow();
- frontWindow=0;
- // It is essential that this is done whenever the front window is closed,
- // otherwise it will seem to the rest of MADE that the window is still open
- break;
-
- case FileQuit:
- applicationHasQuit=true;
- break;
- }
- }
-
- #if Use_AppleEvents
-
- #if Handle_Open_Application_Event
- void MyOpenApplication()
- {
- MyPerformMenu(FileNew);
- }
- #endif
-
- #if Handle_Open_Documents_Event
- void MyOpenDocument(FSSpec* fileSpec)
- {
- }
- #endif
-
- #if Handle_Print_Documents_Event
- void MyPrintDocument(FSSpec* fileSpec)
- {
- }
- #endif
-
- #endif
-
- #if Use_Drag_Manager
-
- RgnHandle MyGetDragRegion(WindowPtr inWindow, Point localPoint, DragReference dragRef)
- {
- RgnHandle hiliteRgn;
-
- hiliteRgn=NewRgn();
- CopyRgn(inWindow->visRgn, hiliteRgn);
-
- return hiliteRgn;
- }
-
- Error MyReceiveDrag(WindowPtr inWindow, Point localPoint, DragReference dragRef)
- {
- return dragNotAcceptedErr;
- }
-
- #endif
-
- #if Support_Modeless_Dialogs
-
- Boolean MyDialogFilter(DialogPtr theDialog, EventRecord* event, short *itemHit)
- {
- char keyCharacter;
-
- if (((event->what==keyDown) || (event->what==autoKey)) && (event->modifiers&cmdKey)) {
- // Catch Command-Key menu equivalents
- keyCharacter=(char)(event->message&charCodeMask);
- MyEnableMenus();
- SelectMenuItem(MenuKey(keyCharacter));
- *itemHit=0; // Specify that no item has been hit
- return true;
- } else
- return false;
- }
-
- void MyHandleDialogEvent(EventRecord* event, DialogPtr theDialog, short itemHit)
- {
- }
-
- #endif
-